package com.cliave.ttweb.controller;

import com.cliave.ttweb.bean.DishesCategory;
import com.cliave.ttweb.service.DishCategoryService;
import com.cliave.ttweb.vo.DishResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/dishCategoryController")
public class DishCategoryController {
    @Autowired
    private DishCategoryService categoryService;
    @RequestMapping("/all")
    public DishResult findDishCategoryAll(){
        List<DishesCategory> list = categoryService.findDishCategoryAll();
        return DishResult.ok().data("categoryList",list);
    }
    @RequestMapping("/delete/{id}")
    public DishResult deleteDishCategory(@PathVariable Integer id){
       int count = categoryService.deleteDishCategory(id);
       return DishResult.ok().data("count",count);
    }
}
